package top.tangyh.lamp.care.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BCareIsbarHandover;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * Mapper 接口
 * ISBAR护理交班表
 * </p>
 *
 * @author zqb
 * @date 2024-08-12 10:28:25
 * @create [2024-08-12 10:28:25] [zqb] [代码生成器生成]
 */
@Repository
public interface BCareIsbarHandoverMapper extends SuperMapper<BCareIsbarHandover> {

    default BCareIsbarHandover selectOneByTime(String startTime, String endTime) {
        LambdaQueryWrapper<BCareIsbarHandover> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.ge(BCareIsbarHandover::getJiaoBanTime, startTime)
                .le(BCareIsbarHandover::getJiaoBanTime, endTime)
                .orderByDesc(BCareIsbarHandover::getJiaoBanTime)
                .last("limit 1");
        return this.selectOne(queryWrapper);
    }

    default IPage<BCareIsbarHandover> selectPageByTime(String startTime, String endTime, Integer page, Integer size) {
        LambdaQueryWrapper<BCareIsbarHandover> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.ge(BCareIsbarHandover::getJiaoBanTime, startTime)
                .le(BCareIsbarHandover::getJiaoBanTime, endTime)
                .orderByDesc(BCareIsbarHandover::getJiaoBanTime);
        IPage<BCareIsbarHandover> iPage = new Page<>(page, size);
        return this.selectPage(iPage, queryWrapper);
    }

}


